package com.example.cofeed.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.api.APIUrl;
import com.example.cofeed.entity.Article;

import java.util.List;

public class HomeRecommendAdapter extends BaseQuickAdapter<Article, BaseViewHolder> {
    public HomeRecommendAdapter() {
        super(R.layout.adapter_recommend);
    }

    @Override
    protected void convert(BaseViewHolder helper, Article item) {

        helper.setText(R.id.tv_title, item.title);
        helper.setText(R.id.tv_source, item.chltitle);

        ImageView imageView = helper.itemView.findViewById(R.id.iv_image);

        RequestOptions options = new RequestOptions()
                .error(R.mipmap.ic_default)
                .placeholder(R.mipmap.ic_default);

        Glide.with(mContext).load(item.img_src)
                .transition(DrawableTransitionOptions.withCrossFade())
                .apply(options).into(imageView);

    }
}
